/*
 * This class is used to build <code>VBlock</code> for a basic block of the source binary code.
 */
#ifndef VBASICBLOCKBUILDER_H
#define VBASICBLOCKBUILDER_H

#include "crossbit/VBlockBuilder.h"

namespace crossbit {

    class VBasicBlockBuilder : public VBlockBuilder {
        public:

            VBasicBlockBuilder() 
                : bb_end(false)
                {}
            // add a new <code>VInst</code> pointer to the <code>bb_vblock</code> in <code>VBlockBuilder</code>
            virtual void add(VInst *inst);

            virtual bool isEnd() { 
                return bb_end; 
            }

            virtual VBlock *wrapUp(XTMemAddr pc) {
                bb_end = false;
                return VBlockBuilder::wrapUp(pc);
            }

        protected:
            // a flag to identify if the <code>VBasiceBlockBuild</code> should stop building the <code>VBlock</code> 
            // if a new added <code>VInst</code> is control transfer instruction, like jump, branch , then
            // <code>bb_end</code> will be set
            bool bb_end;
    };

}

#endif
